/**
  ETFRoot project, Anyang Normal University && IMP-CAS
  \class ETFVisual
  \brief event (2D, 3D) visualization. NOTE that this is a singleton class.
  To be useful, the legacy 2D mode and experimental 3D TGeom mode would both be
  implemented.
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2021-11-13
  \date 2021-12-13 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2021-11-13   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#ifndef ETFVisual_h
#define ETFVisual_h

#include <vector>
#include <Rtypes.h>

class TGraph;
class TCanvas;
class TClonesArray;
class TFile;

class TGeoManager;
class TGeoVolume;
class TGeoMatrix;

using std::vector;

class ETFVisual{
public:
  static ETFVisual *Instance();
  virtual ~ETFVisual();

  virtual void AddNode(TGeoVolume *vol, int copy_no, TGeoMatrix *mat);
  virtual void DrawEventSnap(int ev_index); ///< draw a snap of event evindex

  TGeoVolume *GetTopVolume() const{ return fTop; }
  double GetLength()const { return kL; } ///< length of the canvas
  double GetWidth()const { return kW; } ///< width of the canvas

  ClassDef(ETFVisual, 0); ///< event visualization

protected:
  ETFVisual();
  virtual void Configure(); ///< construct the basics of the visualization
  virtual void ConfigureGeom(); ///< construct the 3D visualization

  static ETFVisual *fInstance;

  static double kL, kW; ///< length and width of the canvas
  TCanvas *fCanvas; ///< the drawing canvas
  TFile *fRootFile; ///< the output root file
  vector<TGraph *> fGraphArr; ///< graph array, collected from all constructed detectors
  TGraph *fGMainFrame; ///< to define the border of the event snap

  TGeoManager *fGeom; ///< the global TGeoManager instance
  TGeoVolume *fTop; ///< the top volume
};

#endif
